﻿using AutoMapper;
using ContactCenter.Core.DomainModel;
using ContactCenter.UI.Web.Models;

namespace ContactCenter.UI.Web.Extensibility
{
    public class ContactInfoTypeConverter : ITypeConverter<ContactInfo, ContactInfoDTO>
    {
        public ContactInfoDTO Convert(ResolutionContext context)
        {
            ContactInfoDTO ci = null;
            var contactInfo = context.SourceValue as ContactInfo;

            if (contactInfo !=null)
            {
                ci = new ContactInfoDTO()
                         {
                             EMail = contactInfo.EMail,
                             WorkPhoneNumber = contactInfo.WorkPhoneNumber,
                             HomePhoneNumber = contactInfo.HomePhoneNumber,
                             MobilePhoneNumber = contactInfo.MobilePhoneNumber
                         };
            }

            return ci;
        }
    }
}